#include "Image.h"

std::map<std::string,jfw::Image*> jfw::Image::ImageList;

jfw::Image::Image(void)
{
}

jfw::Image* jfw::Image::Get(std::string m_sFilename)
{
    std::map<std::string,jfw::Image*>::iterator m_emptyIterator;
    std::map<std::string,jfw::Image*>::iterator m_Iterator = ImageList.find(m_sFilename);
    if (/*ImageList.find(m_sFilename) */ m_Iterator == m_emptyIterator)
    {
        //jfw::Image* m_Image = new jfw::Image();

        ImageList.insert(std::pair<std::string,jfw::Image*>(m_sFilename,new jfw::Image()));
        ImageList[m_sFilename]->LoadFromFile(m_sFilename);
    }

    return ImageList.find(m_sFilename)->second;
}

jfw::Image::~Image()
{
    ImageList.clear();
}
